package com.sailing.xjpb.common.exception;

import com.sailing.xjpb.common.web.ResponseCode;

/**
 * 系统通用业务异常类，对应业务码 {@linkplain ResponseCode#BUSINESS_ERROR}
 *
 * @author YaoWei 2020年10月29日
 */
public class BusinessException extends SailingException {
	private static final long serialVersionUID = 1L;

	public BusinessException(int responseCode, String msg) {
		super(responseCode, msg);
	}

	public BusinessException(int responseCode, String msg, Throwable t) {
		super(responseCode, msg, t);
	}

	public BusinessException(ResponseCode responseStatus, String msg) {
		super(responseStatus, msg);
	}

	public BusinessException(ResponseCode responseStatus, String msg, Throwable t) {
		super(responseStatus, msg, t);
	}

	/**
	 * 业务异常
	 */
	public static SailingException businessError(String message) {
		return new BusinessException(ResponseCode.BUSINESS_ERROR.getCode(), message);
	}

	/**
	 * 业务异常
	 * 如果是SailingException，会直接抛出，否则 转换为business
	 *
	 * @param message 消息信息
	 * @param t       异常
	 * @return com.sailing.xjpb.common.exception.SailingException
	 * @author 罗志银
	 * createDate 2020/12/2 16:15
	 * <p>
	 * editDescription
	 * editUser
	 * editDate 2020/12/2 16:15
	 */
	public static SailingException businessError(String message, Throwable t) {
		return new BusinessException(ResponseCode.BUSINESS_ERROR.getCode(), message, t);
	}
}
